package com.wjc.myktapplication.cusview

import android.content.Context
import android.util.AttributeSet
import androidx.appcompat.widget.AppCompatImageView

/**
 * ClassName: com.wjc.myktapplication.cusview
 * Description:正方形
 * JcChen on 2021.08.31.22:40
 */
class SquareImageView (
    context: Context,
    attrs: AttributeSet,
) : AppCompatImageView(context, attrs) {

    override fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) {
        super.onMeasure(widthMeasureSpec, heightMeasureSpec)
        val newSize = measuredWidth.coerceAtMost(measuredHeight)
        setMeasuredDimension(newSize, newSize)
    }
}